/**
 * node.js 操作数据库之修改数据
 */
const mysql = require('mysql');

let connection = mysql.createConnection({
	host: 'localhost',
	user: 'root',
	password: 'root',
	port: '3306',
	database: 'test'
});

connection.connect();

let modSql = 'UPDATE websites SET name = ?,url = ? WHERE name = ?';
let modSqlParams = ['汪政', 'https://www.google-api.ac.cn', '汪政1'];
//改
connection.query(modSql, modSqlParams, function(err, result) {
	if(err) {
		console.log('[UPDATE ERROR] - ', err.message);
		return;
	}
	console.log('--------------------------UPDATE----------------------------');
	console.log('UPDATE affectedRows', result.affectedRows);
	console.log('-----------------------------------------------------------------\n\n');
});

connection.end();